<!-- src/App.vue -->
<template>
  <div id="app">
    <!-- 导航栏 -->
    <el-menu :default-active="activeIndex" class="el-menu-demo" mode="horizontal" @select="handleSelect">
      <el-menu-item index="1">
        <router-link to="/">首页</router-link>
      </el-menu-item>
      <el-menu-item index="2">
        <router-link to="/restaurant">餐厅</router-link> <!-- 假设有一个默认路径 -->
      </el-menu-item>
      <el-menu-item index="3">
        <router-link to="/user">用户信息</router-link>
      </el-menu-item>
    </el-menu>

    <!-- 页面内容 -->
    <div class="content">
      <router-view></router-view>
    </div>
  </div>
</template>

<script setup>
import { ref } from 'vue'
import { useRoute } from 'vue-router'

const route = useRoute()
const activeIndex = ref(route.name || 'Home')

function handleSelect(key) {
  activeIndex.value = key
}
</script>

<style scoped>
/* 添加一些样式 */
.el-menu-demo {
  margin-bottom: 20px;
}

.content {
  padding: 20px;
}
</style>